home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / perlcl16.lha / perlclass1.6 / perlclass.v < prev    next >
Text File  |  1992-11-10  |  7KB  |  359 lines

  1. x is empty
  2. x.isempty() is true
  3. x is not empty
  4. x.isempty() is false
  5. x.split(a b c d e f)= 6: [0](1)"a"
  6. [1](1)"b"
  7. [2](1)"c"
  8. [3](1)"d"
  9. [4](1)"e"
  10. [5](1)"f"
  11.  
  12. x[0] = (1)"a"
  13. z= x; z[0]="x" z: [0](1)"x"
  14. [1](1)"b"
  15. [2](1)"c"
  16. [3](1)"d"
  17. [4](1)"e"
  18. [5](1)"f"
  19.  
  20. ss= (19)"1.2.3.4.5.6.7.8.9.0", y= ss.split("\."), y=
  21. [0](1)"1"
  22. [1](1)"2"
  23. [2](1)"3"
  24. [3](1)"4"
  25. [4](1)"5"
  26. [5](1)"6"
  27. [6](1)"7"
  28. [7](1)"8"
  29. [8](1)"9"
  30. [9](1)"0"
  31.  
  32. y.join(" ")(19)"1 2 3 4 5 6 7 8 9 0"
  33. (15)"a b c
  34. d e    f   g"
  35. xx.split()= [0](1)"a"
  36. [1](1)"b"
  37. [2](1)"c"
  38. [3](1)"d"
  39. [4](1)"e"
  40. [5](1)"f"
  41. [6](1)"g"
  42.  
  43. (13)"a b c d e f g"
  44. xx.split(",")= [0](13)"a b c d e f g"
  45.  
  46. (20)"  a b c d e f g hi  "
  47. xx.split("")= [0](1)" "
  48. [1](1)" "
  49. [2](1)"a"
  50. [3](1)" "
  51. [4](1)"b"
  52. [5](1)" "
  53. [6](1)"c"
  54. [7](1)" "
  55. [8](1)"d"
  56. [9](1)" "
  57. [10](1)"e"
  58. [11](1)" "
  59. [12](1)"f"
  60. [13](1)" "
  61. [14](1)"g"
  62. [15](1)" "
  63. [16](1)"h"
  64. [17](1)"i"
  65. [18](1)" "
  66. [19](1)" "
  67.  
  68. (18)"a,b,c,d,,e,f,g,,,,"
  69. xx.split(",")= [0](1)"a"
  70. [1](1)"b"
  71. [2](1)"c"
  72. [3](1)"d"
  73. [4](0)""
  74. [5](1)"e"
  75. [6](1)"f"
  76. [7](1)"g"
  77.  
  78. (16)"a,b,c,d,,e,f,g,,"
  79. xx.split(",", 5)= [0](1)"a"
  80. [1](1)"b"
  81. [2](1)"c"
  82. [3](1)"d"
  83. [4](8)",e,f,g,,"
  84.  
  85. (16)" a b c d e f g  "
  86. xx.split(" ")= [0](0)""
  87. [1](1)"a"
  88. [2](1)"b"
  89. [3](1)"c"
  90. [4](1)"d"
  91. [5](1)"e"
  92. [6](1)"f"
  93. [7](1)"g"
  94.  
  95. (13)"a b c d,e,f g"
  96. xx.split("([ ,])+")= [0](1)"a"
  97. [1](1)" "
  98. [2](1)"b"
  99. [3](1)" "
  100. [4](1)"c"
  101. [5](1)" "
  102. [6](1)"d"
  103. [7](1)","
  104. [8](1)"e"
  105. [9](1)","
  106. [10](1)"f"
  107. [11](1)" "
  108. [12](1)"g"
  109.  
  110. (4)",,,,"
  111. xx.split(",")= 
  112. (0)""
  113. xx.split(",")= 
  114. (23)"   a b c    d    e
  115. f  g   "
  116. xx.split("' '")= [0](1)"a"
  117. [1](1)"b"
  118. [2](1)"c"
  119. [3](1)"d"
  120. [4](1)"e"
  121. [5](1)"f"
  122. [6](1)"g"
  123.  
  124. x = [0](1)"a"
  125. [1](1)"b"
  126. [2](1)"c"
  127. [3](1)"d"
  128. [4](1)"e"
  129. [5](1)"f"
  130.  
  131. x.pop() : (1)"f", (1)"e"
  132. x= [0](1)"a"
  133. [1](1)"b"
  134. [2](1)"c"
  135. [3](1)"d"
  136.  
  137. x.shift() : (1)"a", (1)"b"
  138. x= [0](1)"c"
  139. [1](1)"d"
  140.  
  141. x.unshift(y): [0](1)"1"
  142. [1](1)"2"
  143. [2](1)"3"
  144. [3](1)"4"
  145. [4](1)"5"
  146. [5](1)"6"
  147. [6](1)"7"
  148. [7](1)"8"
  149. [8](1)"9"
  150. [9](1)"0"
  151. [10](1)"c"
  152. [11](1)"d"
  153.  
  154. il is empty
  155. il is not empty
  156. il(1, 2, 3, 4) : [0]1 [1]2 [2]3 [3]4 
  157.  
  158. il3= il; il3[0]= 9999; il3 = [0]9999 [1]2 [2]3 [3]4 
  159.  
  160. il= [0]1 [1]2 [2]3 [3]4 
  161.  
  162. il.reverse: [0]4 [1]3 [2]2 [3]1 
  163.  
  164. il1.sort(): [0]1 [1]2 [2]3 [3]4 
  165.  
  166. y = 
  167. [0](3)"one"
  168. [1](3)"two"
  169. [2](5)"three"
  170. [3](4)"four"
  171. y.reverse() [0](4)"four" [1](5)"three" [2](3)"two" [3](3)"one" 
  172.  
  173. y.sort() [0](4)"four" [1](3)"one" [2](5)"three" [3](3)"two" 
  174.  
  175. y.sort().reverse() [0](3)"two" [1](5)"three" [2](3)"one" [3](4)"four" 
  176.  
  177. il2.push(3, 4) : [0]3 [1]4 
  178.  
  179. il.push(il2) : [0]1 [1]2 [2]3 [3]4 [4]3 [5]4 
  180.  
  181. il.pop() : 4, 3
  182. il.unshift(il2) : [0]3 [1]4 [2]1 [3]2 [4]3 [5]4 
  183.  
  184. il.shift() : 3, 4
  185. testing splice:
  186. x = [0](1)"a"
  187. [1](1)"b"
  188. [2](1)"c"
  189. [3](1)"d"
  190. [4](1)"e"
  191. [5](1)"f"
  192. [6](1)"g"
  193. [7](1)"h"
  194. [8](1)"i"
  195.  
  196. z= x.splice(2, 3): z= [0](1)"c"
  197. [1](1)"d"
  198. [2](1)"e"
  199.  
  200. x = [0](1)"a"
  201. [1](1)"b"
  202. [2](1)"f"
  203. [3](1)"g"
  204. [4](1)"h"
  205. [5](1)"i"
  206.  
  207. x.splice(2, 0, z): 
  208. x= [0](1)"a"
  209. [1](1)"b"
  210. [2](1)"c"
  211. [3](1)"d"
  212. [4](1)"e"
  213. [5](1)"f"
  214. [6](1)"g"
  215. [7](1)"h"
  216. [8](1)"i"
  217.  
  218. z.splice(1, 1, x): [0](1)"d" 
  219. z= [0](1)"c"
  220. [1](1)"a"
  221. [2](1)"b"
  222. [3](1)"c"
  223. [4](1)"d"
  224. [5](1)"e"
  225. [6](1)"f"
  226. [7](1)"g"
  227. [8](1)"h"
  228. [9](1)"i"
  229. [10](1)"e"
  230.  
  231. x= [0](1)"a"
  232. [1](1)"b"
  233. [2](1)"c"
  234. [3](1)"d"
  235. [4](1)"e"
  236. [5](1)"f"
  237. [6](1)"g"
  238. [7](1)"h"
  239. [8](1)"i"
  240.  
  241. z.splice(20, 1, x): 
  242. z= [0](1)"c"
  243. [1](1)"a"
  244. [2](1)"b"
  245. [3](1)"c"
  246. [4](1)"d"
  247. [5](1)"e"
  248. [6](1)"f"
  249. [7](1)"g"
  250. [8](1)"h"
  251. [9](1)"i"
  252. [10](1)"e"
  253. [11](1)"a"
  254. [12](1)"b"
  255. [13](1)"c"
  256. [14](1)"d"
  257. [15](1)"e"
  258. [16](1)"f"
  259. [17](1)"g"
  260. [18](1)"h"
  261. [19](1)"i"
  262.  
  263. 4, 3
  264. 101, 5678, 1234
  265. Index check done
  266. 201, 0, 200
  267.  
  268. testing regexp stuff:
  269. x.m(".*X((...)...(...))", "12345Xabcxyzdef") returns 4
  270. subs matched = [0](15)"12345Xabcxyzdef"
  271. [1](9)"abcxyzdef"
  272. [2](3)"abc"
  273. [3](3)"def"
  274.  
  275. rst.m(rexp) returns 1
  276.  
  277. testing grep:
  278. x: 
  279. [0](4)"abcd"
  280. [1](5)"a2345"
  281. [2](5)"X2345"
  282. [3](6)"Xaaaaa"
  283. [4](5)"aaaaa"
  284.  
  285. grep(^a.*)
  286. Expect 3 matches:
  287. [0](4)"abcd"
  288. [1](5)"a2345"
  289. [2](5)"aaaaa"
  290.  
  291. s1= (6)"abcdef", s1.m("^cde") : 0
  292. s1= (6)"abcdef", s1.m("^..cde") : 1
  293. sl = m("(..) (..)", "ab cd ef"); sl = 
  294. [0](2)"ab"
  295. [1](2)"cd"
  296.  
  297. s= (3)"ABC": s.m(ncr)= 1
  298. s= (3)"ABC": s.m(cr)= 0
  299. s.m("abc", "i")= 1
  300. s.m("abc")= 0
  301. test string stuff:
  302. Empty string: (0)"" length= 0,  strlen(s2) = 0
  303. s1:(7)"string1"
  304. s[0]= s, s[5]= g
  305. const char *s= s1: s= string1
  306. s2=s1,  s2:(7)"string1"
  307. s1.chop()(6)"string"
  308. s3= s: s3 = (6)"string"
  309. index("ri") in (6)"string": 2
  310. index((1)"1") in (6)"string": -1
  311. rindex(abc) in(9)"abcabcabc": 6
  312. rindex(abc, 5) in(9)"abcabcabc": 3
  313. substr(5, 3) in (9)"abcabcabc": (3)"cab"
  314. s3.substr(5, 3) = "XXX"(9)"abcabXXXc"
  315. s3.substr(5, 3) = s1(12)"abcabstringc"
  316. s3.substr(5, 3) = s1.substr(1, 3)(12)"abcabtriingc"
  317. s3.substr(0, 6) = s1.substr(0, 3)(9)"strriingc"
  318. s3.substr(-3, 2) = s1.substr(0, 2)(9)"strriistc"
  319. s1 = (10)"1234567890"
  320. s1.substr(0, 10)= s1.substr(1, 9) (9)"234567890"
  321. s1 = (10)"1234567890"
  322. s1.substr(1, 9)= s1.substr(0, 10) (11)"11234567890"
  323. s1.substr(7, 10)= "abcdefghij" (17)"1234567abcdefghij"
  324. s1.substr(10, 5)= "abcdefghij" (20)"1234567890abcdefghij"
  325. s1.substr(20, 1)= "abcdefghij" (20)"1234567890abcdefghij"
  326. (6)"abcdef" + (6)"123456": (12)"abcdef123456"
  327. (6)"abcdef" + "hello"= (11)"abcdefhello"
  328. "hello" + (6)"abcdef"= (11)"helloabcdef"
  329. (6)"abcdef" + 'x' = (7)"abcdefx"
  330. (3)"abc" == (3)"def": 0
  331. (3)"abc" != (3)"def": 1
  332. (3)"abc" == (3)"abc": 1
  333. (3)"abc" != (3)"abc": 0
  334. (3)"abc" < (3)"def": 1
  335. (3)"abc" > (3)"def": 0
  336. (3)"abc" <= (3)"def": 1
  337. (3)"abc" >= (3)"abc": 1
  338. s1 = (9)"abcdefghi", s1.tr("ceg", "123") = 3, s1 = (9)"ab1d2f3hi"
  339. s1.tr("a-z", "A-Z") = 9, s1 = (9)"ABCDEFGHI"
  340. s1.tr("efg", "") = 3, s1 = (9)"abcdefghi"
  341. s1.tr("ac-e", "X") = 4, s1 = (9)"XbXXXfghi"
  342. s1 = (12)"abcdefghiiii", s1.tr("ac-e", "X", "s") = 4, s1 = (10)"XbXfghiiii"
  343. s1.tr("ac-e", "", "d") = 4, s1 = (5)"bfghi"
  344. s1.tr("ac-e", "d", "d") = 4, s1 = (6)"dbfghi"
  345. s1.tr("ac-e", "", "cd") = 5, s1 = (4)"acde"
  346. (10)"bookkeeper": s1.tr("a-zA-Z", "", "s") = 10, s1 = (7)"bokeper"
  347. (15)"abc123def456ghi": s1.tr("a-zA-Z", " ", "c") = 6, s1 = (15)"abc   def   ghi"
  348. (21)"abc123def456ghi789aaa": s1.tr("a-zA-Z", " ", "cs") = 9, s1 = (15)"abc def ghi aaa"
  349. (12)"abcdddaaaxxx": s1.tr("a", "d", "s") = 4, s1 = (9)"dbcdddxxx"
  350. (9)"abcdefghi" s1.s("def", "FED") = 1, s1= (9)"abcFEDghi"
  351. (9)"abcDEFghi" s1.s("def", "FED") = 0, s1= (9)"abcDEFghi"
  352. (9)"abcDEFghi" s1.s("def", "FED", "i") = 1, s1= (9)"abcFEDghi"
  353. (9)"abcdefghi" s1.s("(...)(...)", "\$,$&,$2 $1") = 1, s1= (19)"$,abcdef,def abcghi"
  354. (15)"abcdefabcghiabc" s1.s("abc", "XabcX", "g") = 3, s1= (21)"XabcXdefXabcXghiXabcX"
  355. (15)"abcdefabcghiabc" s1.s("abc", "X", "g") = 3, s1= (9)"XdefXghiX"
  356. (15)"abcdefabcghiabc" s1.s("abc(.)", "X$1abcX$1", "g") = 2, s1= (21)"XdabcXdefXgabcXghiabc"
  357. (15)"abcdefabcghiabc" s1.s("(.)abc", "$1X$1abcX", "g") = 2, s1= (21)"abcdefXfabcXghiXiabcX"
  358. (10)"1234567890" s1.s("(.)(.)", "$2$1", "g") = 5, s1= (10)"2143658709"
  359.